package org.skydiveapplibrary.data;

import java.util.UUID;

import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;

public final class Data
{	
	private static final String[] DEFAULT_AIRCRAFTS = 
	{
		"Caravan",
		"Grand Caravan",
		"Skylane",
		"Stationair",
		"Skyhawk",
		"Pac750",
		"Shorts 330",
	    "Pilatus PC-6 Porter",
		"Skyvan",
		"King Air",
		"Casa C-212 Aviocar",
		"DC3",
		"Hercules (C-130)",
		"Robinson R22 Beta",
	    "Robinson R44 Raven",
	    "Hot Air Balloon",
	    "Twin Otter"
	};
	
	public static void insertDefaultSkydiveTypes(SQLiteDatabase db)
	{
		insertSkydiveType(db, "BASE", FreefallProfileType.Horizontal);
		insertSkydiveType(db, "Belly/RW", FreefallProfileType.Horizontal);
		insertSkydiveType(db, "Freefly", FreefallProfileType.Vertical);
		insertSkydiveType(db, "Hop and Pop", FreefallProfileType.Horizontal);
		insertSkydiveType(db, "Hybrid", FreefallProfileType.Horizontal);
		insertSkydiveType(db, "Skysurfing", FreefallProfileType.Skysurfing);
		insertSkydiveType(db, "Tandem", FreefallProfileType.Horizontal);
		insertSkydiveType(db, "Tracking", FreefallProfileType.Tracking);
		insertSkydiveType(db, "Wingsuit", FreefallProfileType.Wingsuit);
	}
	
	private static void insertSkydiveType(SQLiteDatabase db, String name, FreefallProfileType profile)
	{
		ContentValues values = new ContentValues();
		values.put(Database.SKYDIVE_TYPE_NAME, name);
		values.put(Database.SKYDIVE_TYPE_ACTIVE, true);
		values.put(Database.SKYDIVE_TYPE_FREEFALL_PROFILE, profile.toString());
		values.put(Database.SKYDIVE_TYPE_UNIQUE_ID, UUID.randomUUID().toString());
		db.insert(Database.SKYDIVE_TYPE_TABLE, null, values);
	}
	
	public static void insertDefaltAircrafts(SQLiteDatabase db)
	{
		ContentValues values;
		for (String aircraft: DEFAULT_AIRCRAFTS)
		{
			values = new ContentValues();
			values.put(Database.AIRCRAFT_NAME, aircraft);
			values.put(Database.AIRCRAFT_ACTIVE, true);
			values.put(Database.AIRCRAFT_UNIQUE_ID, UUID.randomUUID().toString());
			db.insert(Database.AIRCRAFT_TABLE, null, values);
		}
	}
	
	public static void insertDefaultSettings(SQLiteDatabase db)
	{
		ContentValues values = new ContentValues();
		values.put(Database.SETTINGS_UNIT_OF_MEASURE, UnitOfMeasure.US.toString());
		values.put(Database.SETTINGS_EXIT_ALTITUDE, 13000);
		values.put(Database.SETTINGS_DEPLOYMENT_ALTITUDE, 3500);
		// do insert
		db.insert(Database.SETTINGS_TABLE, null, values);
	}
}
